package com.utm.gameoka;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.CompoundButton.OnCheckedChangeListener;

public class PartidaAdapter extends BaseAdapter {

	private Activity activity;
	private List<PartidaModel> data;
	private static LayoutInflater inflater = null;

	public PartidaAdapter(Activity actividad, List<PartidaModel> lista) {
		activity = actividad;
		data = lista;
		inflater = (LayoutInflater) activity
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	public int getCount() {
		return data.size();
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		View vi = convertView;
		if (convertView == null)
			vi = inflater.inflate(R.layout.partida_row_componente, null);

		TextView partida = (TextView) vi.findViewById(R.id.lblPartida); // Partida
		TextView fechaPartida = (TextView) vi.findViewById(R.id.lblFechaPartida); // Partida
		//CheckBox chkPartida = (CheckBox) vi.findViewById(R.id.chkPartida); // checkBox
		// ImageView thumb_image=(ImageView)vi.findViewById(R.id.listImage);

		partida.setText("Partida: " + data.get(position).getPartida());
		fechaPartida.setText(data.get(position).getPartida());
		// imageLoader.DisplayImage(l, thumb_image);
		final int pos = position;
		/*chkPartida.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				data.get(pos).setSeleccionado(isChecked);
			}
		});*/

		return vi;
	}
}
